package com.imooc.distributedemo.schedule;

import com.imooc.distributedemo.common.RedisLock;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class SchedulerService {

    @Autowired
    private RedisTemplate redisTemplate;

//    @Scheduled(cron = "0/5 * * * * ?")
    public void sendSms(){
        try(RedisLock redisLock = new RedisLock(redisTemplate,"autoSms",30)){
            if(redisLock.getLock()){
                log.info("向潘多拉发送魔盒");
            }
        }catch (Exception e){
            log.error("出现异常",e);
        }


    }
}
